﻿@using Jugg.Mapping.Setting
@model IEnumerable<SettingMapping>

@{
    ViewBag.Title = "基数设置";
}
  <div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-home home-icon"></i>
            <a href="@Url.RouteUrl("homeIndex")">首页</a>
        </li>
        <li class="active">@ViewBag.Title</li>
    </ul>
</div>
<div class="page-content">
    <div class="page-header">
        <h1>
            @ViewBag.Title
        </h1>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="tabbable">
                <ul class="nav nav-tabs padding-16">
                    <li class="active">
                        <a data-toggle="tab" href="#edit-settings">
                            <i class="purple ace-icon fa fa-cog bigger-125"></i>
                            基数设置
                        </a>
                    </li>
                </ul>
                <div class="tab-content profile-edit-tab-content">
                    <div id="edit-settings" class="tab-pane active">
                        <div class="profile-user-info profile-user-info-striped">
                            <div class="profile-info-row">
                                <div class="profile-info-name">销售人提成金额</div>
                                <div class="profile-info-value">
                                    <span href="javascript:" class="editable editable-click" id="marketer" data-pk="1" data-title="Enter username">
                                        @{
                                            string marketer = "0";
                                            if (Model != null)
                                            {
                                                var markItem = Model.FirstOrDefault(o => o.Name == SettingKey.marketer);
                                                if (markItem != null)
                                                {
                                                    marketer = markItem.Value;
                                                }
                                            }
                                        }
                                        @marketer
                                    </span>元
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name" style="width:200px;"> 上导一级提成金额 </div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click" id="marketerUpLevel" data-pk="1">
                                        @{
                                            string marketerUpLevel = "0";
                                            if (Model != null)
                                            {
                                                var upItem = Model.FirstOrDefault(o => o.Name == SettingKey.marketerUpLevel);
                                                if (upItem != null)
                                                {
                                                    marketerUpLevel = upItem.Value;
                                                }
                                            }
                                        }
                                        @marketerUpLevel
                                    </span>元
                                </div>
                            </div>

                            <div class="profile-info-row">
                                <div class="profile-info-name"> 上导二级提成金额 </div>

                                <div class="profile-info-value">
                                    <span class="editable editable-click" id="marketerTwoLevel" data-pk="1">
                                        @{
                                            string marketerTwoLevel = "0";
                                            if (Model != null)
                                            {
                                                var twoItem = Model.FirstOrDefault(o => o.Name == SettingKey.marketerTwoLevel);
                                                if (twoItem != null)
                                                {
                                                    marketerTwoLevel = twoItem.Value;
                                                }
                                            }
                                        }
                                        @marketerTwoLevel
                                    </span>元
                                </div>
                            </div>

                            <div class="profile-info-row">
                                <div class="profile-info-name"> 税金比例 </div>

                                <div class="profile-info-value">
                                    <span class="editable editable-click" id="taxRate" data-pk="1">
                                        @{
                                            string taxRate = "0";
                                            if (Model != null)
                                            {
                                                var taxRateItem = Model.FirstOrDefault(o => o.Name == SettingKey.taxRate);
                                                if (taxRateItem != null)
                                                {
                                                    taxRate = taxRateItem.Value;
                                                }
                                            }
                                        }
                                        @taxRate
                                    </span>%
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
    $(function () {

        $.fn.editable.defaults.mode = 'inline';
        $.fn.editableform.loading = "<div class='editableform-loading'><i class='ace-icon fa fa-spinner fa-spin fa-2x light-blue'></i></div>";
        $.fn.editableform.buttons = '<button type="submit" class="btn btn-info editable-submit"><i class="ace-icon fa fa-check"></i></button>' +
                                    '<button type="button" class="btn editable-cancel"><i class="ace-icon fa fa-times"></i></button>';
        $('#marketer')
               .editable({
                   ajaxOptions: {
                       type: 'get',
                       dataType: 'json'
                   },
                   spinner: {
                       min: 0,
                       max: 9999,
                       step: 1,
                       on_sides: true
                   },
                   type: 'spinner',
                   name: 'marketer',
                   url: '@Url.RouteUrl("dataSetting")',
                   success: function (response) {
                       if (!response.Status) return response.Message;
                   }
               });

        $('#marketerUpLevel').editable({
            ajaxOptions: {
                type: 'get',
                dataType: 'json'
            },
            type: 'spinner',
            name: 'marketerUpLevel',
            url: '@Url.RouteUrl("dataSetting")',
            spinner: {
                min: 0,
                max: 9999,
                step: 1,
                on_sides: true
            },
            success: function (response, newValue) {
                if (!response.Status) return response.Message;
            }
        });
        $('#marketerTwoLevel').editable({
            ajaxOptions: {
                type: 'get',
                dataType: 'json'
            },
            type: 'spinner',
            name: 'marketerTwoLevel',
            url: '@Url.RouteUrl("dataSetting")',
            spinner: {
                min: 0,
                max: 9999,
                step: 1,
                on_sides: true
            },
            success: function (response, newValue) {
                if (!response.Status) return response.Message;
            }
        });
        $('#taxRate').editable({
            ajaxOptions: {
                type: 'get',
                dataType: 'json'
            },
            type: 'text',
            name: 'taxRate',
            url: '@Url.RouteUrl("dataSetting")',
            spinner: {
                min: 0,
                max: 100,
                step: 1,
                on_sides: true
            },
            success: function (response, newValue) {
                if (!response.Status) return response.Message;
            }
        });
    });
    </script>
</div>